
package br.ufscar.sor.ppgccs.educatransito.util;

/**
 *
 * @author Joaquim
 */
public class Util {

    public String md5(String text) {
        String md5Text = "";
        try {
            java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
            md.update(text.getBytes());

            byte[] bytes = md.digest();

            for (int i = 0; i < bytes.length; i++) {
                md5Text += ((Integer.toHexString((bytes[i] & 0xFF) | 0x100)).substring(1, 3));
            }
        } finally {
            return md5Text;
        }
    }
}
